package com.hsy.sunflowerbao.home.store

import com.flux.action.RxAction
import com.flux.action.RxStoreChange
import com.flux.dispatcher.Dispatcher
import com.hsy.sunflowerbao.base.action.ActionType
import com.hsy.sunflowerbao.base.action.Key
import com.hsy.sunflowerbao.base.data.CommonResult
import com.hsy.sunflowerbao.base.store.BaseStore

/**
 * Created on 2018/3/29.
 *
 * @author Yang
 */
class DetailStore(dispatcher: Dispatcher) : BaseStore(dispatcher) {

    /**
     * 首页数据
     */
    lateinit var result: CommonResult

    override fun onRxAction(action: RxAction) {
        super.onRxAction(action)
        when (action.type) {
            ActionType.CHECK_COUPON -> result = action[Key.CHECK_RESULT]
            else -> return
        }
        //数据变更，发出对应的Action，通知view刷新
        postChange(RxStoreChange(tag, action.type, action.success))
    }
}